

package jogoprojetopi;

import java.awt.Rectangle;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import s3t.gameElements.*;
import s3t.graphicsElements.AnimImage;
import s3t.graphicsElements.ImageCollection;
import s3t.graphicsElements.SimpleImage;

public class LoadIMages {

    public static Scenario scenario = new Scenario("S1", "Cena", 3000, 3000); // criação do cenário
    public static ScenarioLayer predios = new ScenarioLayer("layer1", eScenarioBehavior.SOLID); //layer dos prédios
    public static ScenarioLayer layer0 = new ScenarioLayer("Layer 0", eScenarioBehavior.PASS);
    public static ImageCollection iCollectionBomba = new ImageCollection();
    public static ImageCollection iCollectionIN = new ImageCollection();
    public static ImageCollection iCollectionPL = new ImageCollection();
    public static ScenarioLayer hud; // Criação da HUD do jogo

    
    public LoadIMages(){
    try
        {
            /***************************************CENARIO**************************************/
            //Coleção de imagens dos prédios e a imagem do cenário
            layer0.addScenarioItem(new ScenarioItem("Background", new SimpleImage("/cenario.png"), 1500, 1500));

            //predios 300x300
            predios.addScenarioItem(new ScenarioItem("predio1", new SimpleImage("/300x200.png"), 450, 400));
            predios.addScenarioItem(new ScenarioItem("predio2", new SimpleImage("/300x200.png"), 1950, 400));
            predios.addScenarioItem(new ScenarioItem("predio3", new SimpleImage("/300x200.png"), 2550, 400));
            predios.addScenarioItem(new ScenarioItem("predio4", new SimpleImage("/300x200.png"), 450, 1900));
            predios.addScenarioItem(new ScenarioItem("predio5", new SimpleImage("/300x200.png"), 1050, 1900));

            //predios 300x600
            predios.addScenarioItem(new ScenarioItem("predio6", new SimpleImage("/300x500.png"), 450, 1150));
            predios.addScenarioItem(new ScenarioItem("predio7", new SimpleImage("/300x500.png"), 1950, 1150));
            predios.addScenarioItem(new ScenarioItem("predio8", new SimpleImage("/300x500.png"), 2550, 1150));

            //predios 600x300
            predios.addScenarioItem(new ScenarioItem("predio9", new SimpleImage("/600x200.png"), 1200, 1300));
            predios.addScenarioItem(new ScenarioItem("predio10", new SimpleImage("/600x200.png"), 2400, 1900));
            predios.addScenarioItem(new ScenarioItem("predio11", new SimpleImage("/600x200.png"), 2400, 2500));

            //predio 300x900
            predios.addScenarioItem(new ScenarioItem("predio12", new SimpleImage("/300x800.png"), 1650, 2200));

            //predio 900x300
            predios.addScenarioItem(new ScenarioItem("predio13", new SimpleImage("/900x200.png"), 750, 2500));

            //predio 600x600
            predios.addScenarioItem(new ScenarioItem("predio14", new SimpleImage("/600x500.png"), 1200, 550));

            /***********************************BOMBAS**********************************************/
            //Coloção de imagens da animção de tempo da bomba
            iCollectionBomba.add("BombaTempo1", new SimpleImage("/ImagensDaBomba/bomba_01.png"));
            iCollectionBomba.add("BombaTempo2", new SimpleImage("/ImagensDaBomba/bomba_02.png"));
            iCollectionBomba.add("BombaTempo3", new SimpleImage("/ImagensDaBomba/bomba_03.png"));
            iCollectionBomba.add("BombaTempo4", new SimpleImage("/ImagensDaBomba/bomba_04.png"));
            iCollectionBomba.add("BombaTempo5", new SimpleImage("/ImagensDaBomba/bomba_05.png"));
            iCollectionBomba.add("BombaTempo6", new SimpleImage("/ImagensDaBomba/bomba_06.png"));
            iCollectionBomba.add("BombaTempo7", new SimpleImage("/ImagensDaBomba/bomba_07.png"));
            iCollectionBomba.add("BombaTempo8", new SimpleImage("/ImagensDaBomba/bomba_08.png"));
            iCollectionBomba.add("BombaTempo9", new SimpleImage("/ImagensDaBomba/bomba_09.png"));
            iCollectionBomba.add("BombaTempo10", new SimpleImage("/ImagensDaBomba/bomba_10.png"));
            iCollectionBomba.add("BombaTempo11", new SimpleImage("/ImagensDaBomba/bomba_11.png"));
            iCollectionBomba.add("BombaTempo12", new SimpleImage("/ImagensDaBomba/bomba_12.png"));
            iCollectionBomba.add("BombaTempo13", new SimpleImage("/ImagensDaBomba/bomba_13.png"));
            iCollectionBomba.add("BombaTempo14", new SimpleImage("/ImagensDaBomba/bomba_14.png"));
            iCollectionBomba.add("BombaTempo15", new SimpleImage("/ImagensDaBomba/bomba_15.png"));
            iCollectionBomba.add("BombaTempo16", new SimpleImage("/ImagensDaBomba/bomba_16.png"));
            iCollectionBomba.add("BombaTempo17", new SimpleImage("/ImagensDaBomba/bomba_17.png"));
            iCollectionBomba.add("BombaTempo18", new SimpleImage("/ImagensDaBomba/bomba_18.png"));
            iCollectionBomba.add("BombaTempo19", new SimpleImage("/ImagensDaBomba/bomba_19.png"));
            iCollectionBomba.add("BombaTempo20", new SimpleImage("/ImagensDaBomba/bomba_20.png"));
            iCollectionBomba.add("BombaTempo21", new SimpleImage("/ImagensDaBomba/bomba_21.png"));
            iCollectionBomba.add("BombaTempo22", new SimpleImage("/ImagensDaBomba/bomba_22.png"));
            iCollectionBomba.add("BombaTempo23", new SimpleImage("/ImagensDaBomba/bomba_23.png"));
            iCollectionBomba.add("BombaTempo24", new SimpleImage("/ImagensDaBomba/bomba_24.png"));
            iCollectionBomba.add("BombaTempo25", new SimpleImage("/ImagensDaBomba/bomba_25.png"));
            iCollectionBomba.add("BombaTempo26", new SimpleImage("/ImagensDaBomba/bomba_26.png"));
            iCollectionBomba.add("BombaTempo27", new SimpleImage("/ImagensDaBomba/bomba_27.png"));
            iCollectionBomba.add("BombaTempo28", new SimpleImage("/ImagensDaBomba/bomba_28.png"));
            iCollectionBomba.add("BombaTempo29", new SimpleImage("/ImagensDaBomba/bomba_29.png"));
            iCollectionBomba.add("BombaTempo30", new SimpleImage("/ImagensDaBomba/bomba_30.png"));

            //dersarmar da bomba
            iCollectionBomba.add("desarmando", loadAnimationBomba("/ImagensDaBomba/bomba_desarming_", ".png", 2, 2, AnimImage.GO_AND_BACK));

            //retnângulos de colisão para cada imagem da bomba
            iCollectionBomba.addAttackRectangle("desarmando", new Rectangle(-30,-30,60,60), 0);

            iCollectionBomba.addAttackRectangle("BombaTempo1", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo2", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo3", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo4", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo5", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo6", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo7", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo8", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo9", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo10", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo11", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo12", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo13", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo14", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo15", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo16", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo17", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo18", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo19", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo20", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo21", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo22", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo23", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo24", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo25", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo26", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo27", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo28", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo29", new Rectangle(-14,-20,28,40), 0);
            iCollectionBomba.addAttackRectangle("BombaTempo30", new Rectangle(-14,-20,28,40), 0);

            /******************************INIMIGO***************************************/
            //inimigo estático
            iCollectionIN.add("morra", new SimpleImage("/AnimacaoDoInimigo/enemy_up_dead.png"));

            //inimigo animado
            iCollectionIN.add("andarEsquerda", loadAnimationInimigo("/AnimacaoDoInimigo/enemy_left_", ".png", 5, 4, AnimImage.LOOP_AT_END));
            iCollectionIN.add("andarDireita", loadAnimationInimigo("/AnimacaoDoInimigo/enemy_right_", ".png", 5, 4, AnimImage.LOOP_AT_END));
            iCollectionIN.add("andarCima", loadAnimationInimigo("/AnimacaoDoInimigo/enemy_up_", ".png", 6, 5, AnimImage.LOOP_AT_END));
            iCollectionIN.add("andarBaixo", loadAnimationInimigo("/AnimacaoDoInimigo/enemy_down_", ".png", 6, 5, AnimImage.LOOP_AT_END));

            /***********************************PERSONAGEM*******************************************/
            //personagem estático
            iCollectionPL.add("personagemCima", new SimpleImage("/AnimacaoDoPersonagem/player_idle_up.png"));
            iCollectionPL.add("personagemEsquerda", new SimpleImage("/AnimacaoDoPersonagem/player_idle_left.png"));
            iCollectionPL.add("personagemDireita", new SimpleImage("/AnimacaoDoPersonagem/player_idle_right.png"));
            iCollectionPL.add("personagemBaixo", new SimpleImage("/AnimacaoDoPersonagem/player_idle_down.png"));
            iCollectionPL.add("morraPersonagem", new SimpleImage("/AnimacaoDoPersonagem/player_down_dead.png"));
            //iCollectionPL.add("desarmar", new SimpleImage("/AnimacaoDoPersonagem/player_disarming_2.png"));

            //personagem animações
            iCollectionPL.add("correrEsquerda", loadAnimationPersonagem("/AnimacaoDoPersonagem/player_runing_left_", ".png", 5, 4, AnimImage.LOOP_AT_END));
            iCollectionPL.add("correrDireita", loadAnimationPersonagem("/AnimacaoDoPersonagem/player_runing_right_", ".png", 5, 4, AnimImage.LOOP_AT_END));
            iCollectionPL.add("correrCima", loadAnimationPersonagem("/AnimacaoDoPersonagem/player_runing_up_", ".png", 6, 5, AnimImage.LOOP_AT_END));
            iCollectionPL.add("correrBaixo", loadAnimationPersonagem("/AnimacaoDoPersonagem/player_runing_down_", ".png", 6, 5, AnimImage.LOOP_AT_END));
            iCollectionPL.add("desarmar", loadAnimationPersonagem("/AnimacaoDoPersonagem/player_disarming_", ".png", 2, 2, AnimImage.GO_AND_BACK));
            
            iCollectionPL.addAttackRectangle("desarmar", new Rectangle(10, 10, 5, 8), 0);

            /**************************HUD**********************************************/
            hud = HUD.LoadHUD(hud);
        }
        catch (IOException ex)
        {
            System.out.println("Erro de carregamento de imagem!");
            Logger.getLogger(Cenario.class.getName()).log(Level.SEVERE, null, ex);
        }

    }


    private static AnimImage loadAnimationBomba(String firstName, String extension, int endNumber, int period, int behavior) throws IOException {

        AnimImage animImage = new AnimImage();

        for (int i = 1; i <= endNumber; i++) {
            animImage.addImage(firstName + i + extension);
        }

        animImage.setPeriod(period);
        animImage.setBehavior(behavior);
        return animImage;
    }

    //Função que roda a animação das imagens do inimigo
    private static AnimImage loadAnimationInimigo(String firstName, String extension, int endNumber, int period, int behavior) throws IOException {

        AnimImage animImage = new AnimImage();

        for (int i = 1; i <= endNumber; i++) {
            animImage.addImage(firstName + i + extension);
        }

        animImage.setPeriod(period);
        animImage.setBehavior(behavior);
        return animImage;
    }

    //Função que roda a animação das imagens do personagem
    private static AnimImage loadAnimationPersonagem(String firstName, String extension, int endNumber, int period, int behavior) throws IOException {

        AnimImage animImage = new AnimImage();

        for (int i = 1; i <= endNumber; i++) {
            animImage.addImage(firstName + i + extension);
        }

        animImage.setPeriod(period);
        animImage.setBehavior(behavior);
        return animImage;
    }

}
